//
//  YBBaseViewController.m
//  yunbaolive
//
//  Created by IOS1 on 2019/3/18.
//  Copyright © 2019 cat. All rights reserved.
//

#import "KTBaseViewController.h"
#import "UIViewController+Extension.h"
#import "KTDefines.h"
#define naviBackColor [UIColor whiteColor]
#define naviTFont 15
#define naviTColor kColor(@"#333333")
#import "Masonry.h"
@interface KTBaseViewController ()

@end

@implementation KTBaseViewController

- (BOOL)hideNavigationBar {
    return true;
}

- (void)doReturn{
    [self.navigationController popViewControllerAnimated:YES];
    [self dismissViewControllerAnimated:YES completion:nil];
}

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    [self.navigationController.navigationBar setHidden:true];
}

- (void)creatNavi {
    _naviView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, screen_width, top_safeArea)];
    _naviView.backgroundColor = self.navColor;
    [self.view addSubview:_naviView];
   
    _returnBtn = [UIButton buttonWithType:0];
    [_returnBtn setImage:[UIImage imageNamed:self.backImage] forState:0];
    [_returnBtn addTarget:self action:@selector(doReturn) forControlEvents:UIControlEventTouchUpInside];
    [_naviView addSubview:_returnBtn];
    [_returnBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.inset(0);
        make.width.height.mas_equalTo(40);
        make.bottom.inset(2);
    }];
    
    _titleL = [[UILabel alloc]initWithFrame:CGRectZero];
    _titleL.font = PingFangSC_Medium(16);
    _titleL.textColor = self.titleColor;
    _titleL.text = self.titleString;
    _titleL.textAlignment = NSTextAlignmentCenter;
    [_naviView addSubview:_titleL];
    [_titleL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(_returnBtn);
        make.width.mas_equalTo(160);
        make.height.mas_equalTo(20);
        make.centerX.mas_equalTo(0);
    }];
    
    _rightBtn = [UIButton buttonWithType:0];
    _rightBtn.hidden = YES;
    _rightBtn.titleLabel.font = PingFangSC_Regular(16);
    [_rightBtn setTitleColor:kBlack forState:0];
    [_rightBtn setTitle:self.rightTitle forState:UIControlStateNormal];
    [_rightBtn setTitle:self.sRightTitle forState:UIControlStateSelected];
    [_naviView addSubview:_rightBtn];
    [_rightBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(_titleL);
        make.right.equalTo(_naviView).offset(-10);
    }];
    
    _lineView = [[UIView alloc] init];
    _lineView.backgroundColor = [kColor(@"#F6F6F6") colorWithAlphaComponent:0];
    [_naviView addSubview:_lineView];
    [_lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.bottom.equalTo(_naviView);
        make.height.mas_equalTo(1);
    }];
    
    
//    if ([_backImage isEqualToString:@"返回-白"]) {
//        [_naviView setGradientBackgroundWithColors:@[kColor(@"#F88487"),kColor(@"#F6676A"),kColor(@"#F7686B")] locations:@[@0,@0.5,@1] startPoint:CGPointMake(0,0) endPoint:CGPointMake(0, 1)];
//        _lineView.hidden = true;
//    }
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navColor = [UIColor clearColor];
    self.titleColor = [UIColor whiteColor];
    self.backImage = @"返回";
    
    self.navigationController.interactivePopGestureRecognizer.delegate = nil;
    self.navigationController.navigationBar.hidden = YES;
    
    if ([[UIDevice currentDevice] systemVersion].floatValue >= 11.0) {
        self.automaticallyAdjustsScrollViewInsets = NO;
    }
    self.view.backgroundColor = [UIColor whiteColor];
}




@end
